<?php 
require_once '../common.php';
if (empty($_POST['step'])) {
	include atemplate('login');
} else {
	$username = trim($_POST['username']);
	$password = trim($_POST['password']);
	$mdpassword = md5($password);
	$count = $db->result($db->query("select count(*) from ".tname('admin')." where username = '$username' and password = '$mdpassword'"),0);
	if ($count >0) {
		ssetcookie('auth', authcode("$username\t$password", 'ENCODE'), 0);
		showmessage('登录成功','index.php?',1);
	} else {
		showmessage('用户名或密码错误');
	}
}
?>